start = 11;
X=15;
n=1;

%time_cpu = [];
time_gpu = [];

for j=start:X
    N=2^j; 

%     profile on;
%     for i=1:n
%         acma_koen();
%     end;
%     %profile viewer
%     
%     p= profile('info');
%     
%     aa = size(p.FunctionTable);
%     for z=1:aa(1)
%         if (strcmp(p.FunctionTable(z).FunctionName, 'acma_koen'))
%             time_cpu(j) = p.FunctionTable(z).TotalTime;
%         end;
%     end;
%     
%     profsave(p, sprintf('profile_results_cpu_%d', N));
%     profile off;

    profile on;
    for i=1:n
        acma_gpu();
    end;
    %profile viewer
    p= profile('info');
    
    aa = size(p.FunctionTable);
    for z=1:aa(1)
        if (strcmp(p.FunctionTable(z).FunctionName, 'acma_gpu'))
            time_gpu(j) = p.FunctionTable(z).TotalTime;
        elseif (strcmp(p.FunctionTable(z).FunctionName, 'GPUArray.mtimes'))
            time_mtimes(j) = p.FunctionTable(z).TotalTime;
        elseif (strcmp(p.FunctionTable(z).FunctionName, 'repmat'))
            time_repmat(j) = p.FunctionTable(z).TotalTime;
        elseif (strcmp(p.FunctionTable(z).FunctionName, 'gpuArray'))
            time_gpuarray(j) = p.FunctionTable(z).TotalTime;
        end;
    end;
    
    profsave(p, sprintf('profile_results_gpu_%d', N));
    
    profile off;

end;


